home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / panel.c < prev    next >
C/C++ Source or Header  |  1979-12-31  |  4KB  |  183 lines

  1. /* --------------------------------- panel.c -------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* show the control panel data.
  8. */
  9.  
  10. #include "plane.h"
  11.  
  12.  
  13. #define GEARVLIMIT    (150*VONE)
  14.  
  15. extern void FAR
  16. show_panel (VIEW *view, OBJECT *p, int maxx, int maxy, int orgx, int orgy,
  17.     int ss)
  18. {
  19.     int    hud, hud1, knots, blink;
  20.     int    xl, xr, y, x0, y0, dm, dd, ch;
  21.     long    t;
  22.  
  23.     hud = EX->hud;
  24.     hud1 = EX->hud1;
  25.     knots = hud1 & HUD_KNOTS;
  26.     blink = ((int)st.present)&0x0080;
  27.  
  28.     dd = num_size (9L, ss);
  29.  
  30.     dm = dd*3/2;
  31.     xr = orgx + maxx - 7*dd;
  32.     xl = xr - 7*dd;
  33.     y = orgy + maxy - 2;
  34.     y0 = ss*3/2;
  35.  
  36.     if (EX->flags & PF_CHASE) {
  37.         if (EX->target)
  38.             stroke_str (xl, y, "CHASE", ss, ST_HFG);
  39.         else
  40.             stroke_str (xl, y, "AUTO", ss, ST_HFG);
  41.     }
  42.     if (EX->flags & PF_KILL)
  43.         stroke_str (xr, y, "KILL", ss, ST_HFG);
  44.     y -= ss;
  45.  
  46.     if (EX->brake) {
  47.         stroke_str (xl, y, "BRK", ss, ST_HFG);
  48.         stroke_num (xl+dm+2*dd, y, EX->brake, ss, ST_HFG);
  49.     }
  50.     if (EX->flags & PF_ONGROUND)
  51.         stroke_str (xr, y, "TAXI", ss, ST_HFG);
  52.     else if (EX->equip & EQ_GEAR) {
  53.         if (p->speed < GEARVLIMIT || blink)
  54.             stroke_str (xr, y, "GEAR", ss, ST_HFG);
  55.     } else if (EX->fuelRate) {
  56.         int    mm, hh;
  57.  
  58.         mm = (int)(EX->fuel / (60L*EX->fuelRate));
  59.         hh = mm / 60;
  60.         mm -= 60*hh;
  61.         if (hh > 99)
  62.             hh = mm = 99;
  63.         stroke_str (xr, y, "FT", ss, ST_HFG);
  64.         x0 = xr+dm+dd;
  65.         x0 += stroke_num (x0, y, hh, ss, ST_HFG);
  66.         x0 += stroke_char (x0, y, ':', ss, ST_HFG);
  67.         stroke_frac (x0, y, mm, 2, 0, ss, ST_HFG);
  68.     }
  69.     y -= y0;
  70.  
  71.     stroke_char (xl, y, 'D', ss, ST_HFG);
  72.     stroke_num (xl+dm, y, (long)p->damage, ss, ST_HFG);
  73.     stroke_char (xr, y, 'F', ss, ST_HFG);
  74.     stroke_num (xr+dm, y, EX->fuel/100, ss, ST_HFG);
  75.     y -= ss;
  76.  
  77.     if (EX->spoilers) {
  78.         stroke_str (xl, y, "SPL", ss, ST_HFG);
  79.         stroke_num (xl+dm+2*dd, y, EX->spoilers, ss,
  80.                 ST_HFG);
  81.     }
  82.     if (EX->flaps) {
  83.         stroke_str (xr, y, "FLP", ss, ST_HFG);
  84.         stroke_num (xr+dm+2*dd, y, EX->flaps, ss,
  85.                 ST_HFG);
  86.     }
  87.     y -= ss;
  88.  
  89.     if (EX->rudder) {
  90.         stroke_str (xl, y, (EX->rudder > 0) ? "RDL" : "RDR",
  91.             ss, ST_HFG);
  92.         t = abs(EX->rudder);
  93.         x0 = xl+dm+2*dd;
  94.         x0 += stroke_num (x0, y, t , ss, ST_HFG);
  95.     }
  96.     if (EX->airbrake) {
  97.         if (blink) {
  98.             stroke_str (xr, y, "AIR", ss, ST_HFG);
  99.             stroke_num (xr+dm+2*dd, y, EX->airbrake, ss, ST_HFG);
  100.         }
  101.     } else {
  102.         stroke_str (xr, y, "TST", ss, ST_HFG);
  103.         t = (int)(EX->thrust * 100L / EP->ab_thrust);
  104.         stroke_num (xr+dm+2*dd, y, t, ss, ST_HFG);
  105.     }
  106.     y -= y0;
  107.  
  108.     stroke_char (xl, y, 'T', ss, ST_HFG);
  109.     t = EX->throttle + EX->afterburner/20;
  110.     stroke_num (xl+dm, y, t, ss, ST_HFG);
  111. #if 0
  112.     stroke_char (xr, y, 'E', ss, ST_HFG);
  113.     t = (int)(EX->thrust * 100L / EP->mil_thrust);
  114. #else
  115.     stroke_char (xr, y, 'P', ss, ST_HFG);
  116.     t = EX->power / 100;
  117. #endif
  118.     stroke_num (xr+dm, y, t, ss, ST_HFG);
  119.     y -= y0;
  120.     if (EX->hdd & HDD_NAV) {
  121.  
  122. /* Show simple x/y from home.
  123. */
  124.         t = p->R[Y]/(VONE*10);
  125.         if (knots)
  126.             t = t * 54 / 100;
  127.         if (t < 0) {
  128.             ch = 'S';
  129.             t = -t;
  130.         } else
  131.             ch = 'N';
  132.         stroke_char (xl, y, ch, ss, ST_HFG);
  133.         stroke_frac (xl+dm, y, t, 0, 2, ss, ST_HFG);
  134.  
  135.         t = p->R[X]/(VONE*10);
  136.         if (knots)
  137.             t = t * 54 / 100;
  138.         if (t < 0) {
  139.             ch = 'W';
  140.             t = -t;
  141.         } else
  142.             ch = 'E';
  143.         stroke_char (xr, y, ch, ss, ST_HFG);
  144.         stroke_frac (xr+dm, y, t, 0, 2, ss, ST_HFG);
  145.         y -= ss;
  146. /*
  147.  * Show correct latitude/longitude.
  148. */
  149.         if (p->flags & F_KEEPNAV) {
  150.             t = p->latitude;
  151.             if (t < 0) {
  152.                 ch = 'S';
  153.                 t = -t;
  154.             } else
  155.                 ch = 'N';
  156.             x0 = xl;
  157.             x0 += stroke_char (x0, y, ch, ss, ST_HFG);
  158.             x0 += dd/2;
  159.             x0 += stroke_frac (x0, y, t/60, 2, 0, ss, ST_HFG);
  160.             x0 += stroke_char (x0, y, ':',        ss, ST_HFG);
  161.                   stroke_frac (x0, y, t%60, 2, 0, ss, ST_HFG);
  162.  
  163.             t = p->longitude;
  164.             if (t < 0) {
  165.                 ch = 'W';
  166.                 t = -t;
  167.             } else
  168.                 ch = 'E';
  169.             x0 = xr;
  170.             x0 += stroke_char (x0, y, ch, ss, ST_HFG);
  171.             x0 += dd/2;
  172.             x0 += stroke_frac (x0, y, t/60, 3, 0, ss, ST_HFG);
  173.             x0 += stroke_char (x0, y, ':',        ss, ST_HFG);
  174.                   stroke_frac (x0, y, t%60, 2, 0, ss, ST_HFG);
  175.             y -= ss;
  176.         }
  177.         stroke_str (xl, y, (char *)show_time ("TIME ", st.present), ss,
  178.             ST_HFG);
  179.     }
  180. }
  181.  
  182. #undef GEARVLIMIT
  183.